package com.joysuch.wwyt.quartz.createtable.constant;

/**
 * 创建表脚本常量类
 *
 * @author 叶君翔
 * @date 2023/07/11 10:47
 */
public interface CreateTableScriptConstant {

    String INVESTIGATE_TASK = "CREATE TABLE `%s` (\n" +
            "  `id` bigint(20) NOT NULL,\n" +
            "  `plan_id` bigint(20) NOT NULL COMMENT '排查计划id',\n" +
            "  `user_id` bigint(20) DEFAULT NULL COMMENT '排查人员id',\n" +
            "  `check_date` datetime DEFAULT NULL COMMENT '排查日期',\n" +
            "  `deadline` datetime DEFAULT NULL COMMENT '截至日期',\n" +
            "  `source_type` int(4) DEFAULT '0' COMMENT '数据来源类型',\n" +
            "  `status` varchar(10) NOT NULL COMMENT '状态',\n" +
            "  `record_id` bigint(20) DEFAULT NULL COMMENT '记录id',\n" +
            "  `period_unit` varchar(64) DEFAULT NULL COMMENT '周期单位: 日; 月',\n" +
            "  `period_days` int(11) DEFAULT NULL COMMENT '日/月 周期设置,eg: 按天 每1天',\n" +
            "  `check_rate_describe` varchar(512) DEFAULT NULL COMMENT '排查频次',\n" +
            "  `check_end_date` date DEFAULT NULL COMMENT '排查日期',\n" +
            "  `district_id` bigint(20) DEFAULT NULL COMMENT '风险区域',\n" +
            "  `depart_id` bigint(20) DEFAULT NULL COMMENT '风险区域所属部门',\n" +
            "  `tenent_id` bigint(20) DEFAULT NULL,\n" +
            "  `org_code` varchar(64) DEFAULT NULL,\n" +
            "  `delete_flag` enum('1','0') DEFAULT '0',\n" +
            "  `create_by` bigint(20) DEFAULT NULL,\n" +
            "  `create_time` datetime DEFAULT NULL,\n" +
            "  `update_by` bigint(20) DEFAULT NULL,\n" +
            "  `update_time` datetime DEFAULT NULL,\n" +
            "  `finish_date` datetime DEFAULT NULL COMMENT '任务完成时间',\n" +
            "  PRIMARY KEY (`id`) USING BTREE,\n" +
            "  KEY `mixIndex` (`check_date`,`status`) USING BTREE,\n" +
            "  KEY `userIdIndex` (`user_id`) USING BTREE,\n" +
            "  KEY `planIdIndex` (`plan_id`) USING BTREE,\n" +
            "  KEY `statusindex` (`status`) USING BTREE,\n" +
            "  KEY `idx_depart` (`depart_id`) USING BTREE\n" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;";

    String INVESTIGATE_TASK_ASSIGN = "CREATE TABLE `%s` (\n" +
            "  `id` bigint(20) NOT NULL,\n" +
            "  `task_id` bigint(20) NOT NULL COMMENT '任务id',\n" +
            "  `assign_user` bigint(20) DEFAULT NULL COMMENT '分配用户',\n" +
            "  `summary_id` bigint(20) DEFAULT NULL COMMENT '汇总任务Id',\n" +
            "  `create_by` bigint(20) DEFAULT NULL,\n" +
            "  `create_time` datetime DEFAULT NULL,\n" +
            "  `update_by` bigint(20) DEFAULT NULL,\n" +
            "  `update_time` datetime DEFAULT NULL,\n" +
            "  `org_code` varchar(64) DEFAULT NULL,\n" +
            "  `tenent_id` bigint(20) DEFAULT NULL,\n" +
            "  `delete_flag` enum('0','1') DEFAULT NULL,\n" +
            "  PRIMARY KEY (`id`),\n" +
            "  KEY `idx_assign_user` (`assign_user`) USING BTREE,\n" +
            "  KEY `idx_summary_id` (`summary_id`) USING BTREE,\n" +
            "  KEY `idx_task_id` (`task_id`) USING BTREE\n" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";

    String INVESTIGATE_TASK_SUMMARY = "CREATE TABLE `%s` (\n" +
            "  `id` bigint(20) NOT NULL,\n" +
            "  `user_id` bigint(20) NOT NULL COMMENT '用户id',\n" +
            "  `check_name` varchar(64) DEFAULT NULL COMMENT '检查名称',\n" +
            "  `check_type` varchar(64) DEFAULT NULL COMMENT '排查类型',\n" +
            "  `check_user_ids` varchar(500) DEFAULT NULL COMMENT '排查人员ids',\n" +
            "  `check_date` datetime DEFAULT NULL COMMENT '排查日期',\n" +
            "  `check_complete_user_id` bigint(20) DEFAULT NULL COMMENT '最后一个完成排查人',\n" +
            "  `check_complete_date` datetime DEFAULT NULL COMMENT '排查实际完成日期',\n" +
            "  `check_result` varchar(64) DEFAULT NULL COMMENT '排查结果',\n" +
            "  `check_status` varchar(64) DEFAULT NULL COMMENT '排查状态',\n" +
            "  `exception_process_result` varchar(64) DEFAULT NULL COMMENT '异常处理结果',\n" +
            "  `create_by` bigint(20) DEFAULT NULL,\n" +
            "  `create_time` datetime DEFAULT NULL,\n" +
            "  `update_by` bigint(20) DEFAULT NULL,\n" +
            "  `update_time` datetime DEFAULT NULL,\n" +
            "  `tenent_id` bigint(20) DEFAULT NULL,\n" +
            "  `org_code` varchar(64) DEFAULT NULL,\n" +
            "  `delete_flag` enum('1','0') DEFAULT '0',\n" +
            "  `has_process_record` tinyint(1) DEFAULT '0' COMMENT '是否有任务处理记录',\n" +
            "  `task_count` int(8) NOT NULL DEFAULT '0' COMMENT '任务总数',\n" +
            "  `task_done_count` int(8) NOT NULL DEFAULT '0' COMMENT '任务完成数',\n" +
            "  `uncheck_count` int(8) NOT NULL DEFAULT '0' COMMENT '未检数',\n" +
            "  `time_out_check_count` int(8) NOT NULL DEFAULT '0' COMMENT '逾期完成数',\n" +
            "  `exception_count` int(8) NOT NULL DEFAULT '0' COMMENT '发现异常数',\n" +
            "  `source_type` int(1) NOT NULL DEFAULT '1' COMMENT '数据来源1:风险管控，0:排查表',\n" +
            "  `task_id` bigint(20) DEFAULT NULL COMMENT '关联任务Id（排查表使用）',\n" +
            "  PRIMARY KEY (`id`),\n" +
            "  KEY `idx_task` (`task_id`) USING BTREE,\n" +
            "  KEY `idx_user_id` (`user_id`) USING BTREE\n" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";


    String INVESTIGATE_RECORD = "CREATE TABLE `%s` (\n" +
            "  `id` bigint(20) NOT NULL,\n" +
            "  `check_plan_id` bigint(20) NOT NULL COMMENT '检查计划Id',\n" +
            "  `check_user_id` bigint(20) DEFAULT NULL COMMENT '排查用户Id',\n" +
            "  `check_finish_date` datetime DEFAULT NULL COMMENT '排查完成日期',\n" +
            "  `exception_sum` int(11) DEFAULT NULL COMMENT '异常总数',\n" +
            "  `exception_handle_status` varchar(10) DEFAULT NULL COMMENT '异常处理状态',\n" +
            "  `remark` text COMMENT '备注',\n" +
            "  `check_result` varchar(64) DEFAULT NULL COMMENT '检查结果',\n" +
            "  `source_type` int(4) DEFAULT '0' COMMENT '数据来源类型',\n" +
            "  `verify_location` varchar(256) DEFAULT NULL COMMENT '签到位置',\n" +
            "  `verify_type` varchar(64) DEFAULT NULL COMMENT '签到方式:nfc，定位',\n" +
            "  `verify_state` varchar(64) DEFAULT NULL COMMENT '签到状态',\n" +
            "  `uncheck_reason` varchar(64) DEFAULT NULL COMMENT '未检原因eg：\"超时未检\"，\"异常未检\"',\n" +
            "  `create_by` bigint(20) DEFAULT NULL,\n" +
            "  `create_time` datetime DEFAULT NULL,\n" +
            "  `duty_depart_id` bigint(20) DEFAULT NULL COMMENT '责任部门',\n" +
            "  `update_by` bigint(20) DEFAULT NULL,\n" +
            "  `task_id` bigint(20) DEFAULT NULL COMMENT '任务表id',\n" +
            "  `update_time` datetime DEFAULT NULL,\n" +
            "  `tenent_id` bigint(20) DEFAULT NULL,\n" +
            "  `org_code` varchar(64) DEFAULT NULL,\n" +
            "  `delete_flag` enum('0','1') DEFAULT '0',\n" +
            "  `participants` text COMMENT '参与人员Json',\n" +
            "  PRIMARY KEY (`id`) USING BTREE,\n" +
            "  KEY `userIdIndex` (`check_user_id`) USING BTREE,\n" +
            "  KEY `planIdIndex` (`check_plan_id`) USING BTREE,\n" +
            "  KEY `checkResultIndex` (`check_result`) USING BTREE,\n" +
            "  KEY `finishDateIndex` (`check_finish_date`) USING BTREE,\n" +
            "  KEY `task_id_index` (`task_id`) USING BTREE\n" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;";

    String INVESTIGATE_RECORD_ITEM = "CREATE TABLE `%s` (\n" +
            "  `id` bigint(20) NOT NULL,\n" +
            "  `record_id` bigint(20) NOT NULL COMMENT '排查记录Id',\n" +
            "  `check_item_id` bigint(20) DEFAULT NULL COMMENT '排查项目Id',\n" +
            "  `problem_description` varchar(512) DEFAULT NULL COMMENT '问题描述',\n" +
            "  `attachment_json` text COMMENT '图片json',\n" +
            "  `action` varchar(10) DEFAULT NULL COMMENT '状态',\n" +
            "  `repair_status` varchar(10) DEFAULT NULL COMMENT '整改状态',\n" +
            "  `work_flow_task_id` bigint(20) DEFAULT NULL COMMENT '关联流程任务数据id',\n" +
            "  `wf_process_ins_id` varchar(64) DEFAULT NULL COMMENT '新版-关联流程id',\n" +
            "  `wf_process_status` varchar(64) DEFAULT NULL COMMENT '新版-关联流程状态',\n" +
            "  `create_by` bigint(20) DEFAULT NULL,\n" +
            "  `create_time` datetime DEFAULT NULL,\n" +
            "  `update_by` bigint(20) DEFAULT NULL,\n" +
            "  `update_time` datetime DEFAULT NULL,\n" +
            "  `tenent_id` bigint(20) DEFAULT NULL,\n" +
            "  `org_code` varchar(64) DEFAULT NULL,\n" +
            "  `delete_flag` enum('0','1') DEFAULT '0',\n" +
            "  PRIMARY KEY (`id`),\n" +
            "  KEY `recordIdIndex` (`record_id`) USING BTREE,\n" +
            "  KEY `idx_procins` (`wf_process_ins_id`),\n" +
            "  KEY `idx_create_time` (`create_time`)\n" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";

}
